<?php

namespace App\Admin\Controllers;

use App\Services\FcustomerService;
use Slowlyo\OwlAdmin\Controllers\AdminController;

/**
 * 客户管理
 *
 * @property FcustomerService $service
 */
class FcustomerController extends AdminController
{
	protected string $serviceName = FcustomerService::class;

	public function list()
	{
		$crud = $this->baseCRUD()
			->filterTogglable(false)
			->headerToolbar([
				$this->createButton('dialog'),
				...$this->baseHeaderToolBar()
			])
			->columns([
				amis()->TableColumn('id', 'ID')->sortable(),
				amis()->TableColumn('short_name', '客户简称'),
				amis()->TableColumn('customer_name', '客户全称'),
				
				amis()->TableColumn('customer_address', '客户地址'),
				amis()->TableColumn('business_email', '商务邮箱'),
				amis()->TableColumn('ops_email', '运维邮箱'),
				amis()->TableColumn('cutover_email', '割接邮箱'),
				amis()->TableColumn('violation_email', '违规邮箱'),
				amis()->TableColumn('bd_uid.name', '对接人'),
				amis()->TableColumn('created_at', admin_trans('admin.created_at'))->type('datetime')->sortable(),
				$this->rowActions('dialog')
			]);

		return $this->baseList($crud);
	}

	public function form($isEdit = false)
	{
		return $this->baseForm()->body([
			amis()->TextControl('short_name', '客户简称'),
			amis()->TextControl('customer_name', '客户全称'),

			amis()->TextControl('customer_address', '客户地址'),
			amis()->TextControl('business_email', '商务邮箱'),
			amis()->TextControl('ops_email', '运维邮箱'),
			amis()->TextControl('cutover_email', '割接邮箱'),
			amis()->TextControl('violation_email', '违规邮箱'),
			amis()->SelectControl('bd_uid', '对接人')
				->searchable(true)
				->source('/system/admin_users?_action=getData')
				->labelField('name')
				->valueField('id'),
		]);
	}

	public function detail()
	{
		return $this->baseDetail()->body([
			amis()->TextControl('id', 'ID')->static(),
			amis()->TextControl('customer_address', '客户地址')->static(),
			amis()->TextControl('customer_name', '客户全称')->static(),
			amis()->TextControl('cutover_email', '割接邮箱')->static(),
			amis()->TextControl('editor_uid', '编辑人UID')->static(),
			amis()->TextControl('end_ip_address', '结束ip')->static(),
			amis()->TextControl('fip_address', 'ip归属段')->static(),
			amis()->TextControl('ip_address', 'IP地址')->static(),
			amis()->TextControl('is_delete', '是否删除：0-未删除 1-已删除')->static(),
			amis()->TextControl('operator_uid', '操作人UID')->static(),
			amis()->TextControl('ops_email', '运维邮箱')->static(),
			amis()->TextControl('sign_company', '签约公司')->static(),
			amis()->TextControl('start_ip_address', '开始ip')->static(),
			amis()->TextControl('violation_email', '违规邮箱')->static(),
			amis()->TextControl('created_at', admin_trans('admin.created_at'))->static(),
			amis()->TextControl('updated_at', admin_trans('admin.updated_at'))->static(),
		]);
	}
}